package com.coffeeloversupportlibrary.coffeelover.domain.coffeebean.adapter;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import androidx.viewpager.widget.ViewPager;

import com.coffeeloversupportlibrary.R;
import com.coffeeloversupportlibrary.coffeelover.domain.article.entity.Article;
import com.coffeeloversupportlibrary.coffeelover.uicompont.conflict.NestedScrollingParent2LayoutImpl3;
import com.coffeeloversupportlibrary.databinding.BeansContentListBinding;


import java.util.ArrayList;
import java.util.List;

/**
 * @author puyv
 * @createTime 2021/11/12 13:11
 * @projectName CoffeeLoverSupportLibrary
 * @className BeansListFragment.java
 * @description TODO
 */
public class BeansListFragment extends Fragment {
    private BeansContentListBinding beansContentListBinding;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        beansContentListBinding= DataBindingUtil.inflate(inflater, R.layout.beans_content_list,container,false);
        initView();
        return beansContentListBinding.getRoot();
    }


    private void initView(){
        beansContentListBinding.beanView.setLayoutManager(new LinearLayoutManager(getContext()));
        beansContentListBinding.beanView.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL));
        beansContentListBinding.beanView.setAdapter(create());
    }

    private BeansListAdapter create(){
        List<Article> lists=new ArrayList<>();
//        Article article1=new Article("coffeeLover",R.drawable.coffee,"文章ID1");
//        Article article2=new Article("coffeeLover",R.drawable.coffee2,"文章ID2");
//        Article article3=new Article("coffeeLover",R.drawable.coffee3,"文章ID3");
//        Article article4=new Article("coffeeLover",R.drawable.cooffee4,"文章ID4");


//        lists.add(article1);
//        lists.add(article2);
//        lists.add(article3);
//        lists.add(article4);
//        lists.add(article1);
//        lists.add(article2);
//        lists.add(article3);
//        lists.add(article4);
//        lists.add(article1);
//        lists.add(article2);
//        lists.add(article3);
//        lists.add(article4);
//        lists.add(article1);
//        lists.add(article2);
//        lists.add(article3);
//        lists.add(article4);
//        lists.add(article1);
//        lists.add(article2);
//        lists.add(article3);

        return new BeansListAdapter(lists);
    }

}
